<?php

namespace frontendx\models;

/**
 * @author  shuang
 * @date    2016-11-14 19:29:02
 * @version V1.0
 * @desc    
 */
use common\models\Article;
use Yii;

class WB_Article extends Article {
    /*
     * 查询刷手帮助信息资料
     */

    public static function getArticleList() {
        $query = WB_Article::find()->orderBy("created_at desc");
        $query->where("typeid=:typeid", [":typeid" => 41]);
        $query->andWhere("find_in_set('c',flags)");
        $countQuery = clone $query;
        $pager = new \yii\data\Pagination(['totalCount' => $countQuery->count(), 'defaultPageSize' => 10]);
        $offset = Yii::$app->request->get("offset");
        $limit = Yii::$app->request->get("limit");
        $res = $query->offset($offset)->limit($limit)->all();
        return ["pager" => $pager, "data" => $res];
    }

    /*
     * 查询商户最新公告
     */

    public static function getNewNotice() {
        $query = WB_Article::find()->where("typeid=:typeid", [":typeid" => 44])->orderBy("updated_at desc");
        $query->andWhere("find_in_set('c',flags)");
        return $query->one();
    }

}
